package com.guoxin.principle.di.improve;

public class DependencyInversion {

    public static void main(String[] args) {
        Person p = new Person();
        p.receive(new Email());
        p.receive(new WeXin());
    }
}

interface IReceive {
    String getInfo();
}

class Email implements IReceive {

    @Override
    public String getInfo() {
        return "电子邮件信息：hello world";
    }
}

class WeXin implements IReceive {

    @Override
    public String getInfo() {
        return "微信信息：hello world";
    }
}

class Person {

    public void receive(IReceive receive) {
        System.out.println(receive.getInfo());
    }
}
